package com.tangyuan.common.exception.file;

import lombok.Getter;

import java.util.Arrays;

/**
 * @描述: 文件上传错误异常类
 * @Author: TangYuan
 * @Date: 2024/9/20 下午4:18
 */
@Getter
public class InvalidExtensionException extends FileUploadException {
    
    private final String[] allowedExtension;
    private final String extension;
    private final String filename;
    
    public InvalidExtensionException(String[] allowedExtension, String extension, String filename) {
        super("文件[" + filename + "]后缀[" + extension + "]不正确，请上传" + Arrays.toString(allowedExtension) + "格式");
        this.allowedExtension = allowedExtension;
        this.extension = extension;
        this.filename = filename;
    }
    
    public static class InvalidImageExtensionException extends InvalidExtensionException {
        
        public InvalidImageExtensionException(String[] allowedExtension, String extension, String filename) {
            super(allowedExtension, extension, filename);
        }
    }
    
    public static class InvalidFlashExtensionException extends InvalidExtensionException {
        
        public InvalidFlashExtensionException(String[] allowedExtension, String extension, String filename) {
            super(allowedExtension, extension, filename);
        }
    }
    
    public static class InvalidMediaExtensionException extends InvalidExtensionException {
        
        public InvalidMediaExtensionException(String[] allowedExtension, String extension, String filename) {
            super(allowedExtension, extension, filename);
        }
    }
    
    public static class InvalidVideoExtensionException extends InvalidExtensionException {
        
        public InvalidVideoExtensionException(String[] allowedExtension, String extension, String filename) {
            super(allowedExtension, extension, filename);
        }
    }
}
